clear all
set more off

local out2="\outregsQJE\"
cd "\workfiles"

use step001_QJE_2, clear

tsset firm_id time

*** define treatment as given inflation TIMES treatment status
gen Treat=treatment_old*infl

*** restrict the sample only to the period with treatment and control groups
keep if time>=210

***======================================================
*** 			responses by horizon
***				longests sample
***				Panel A
***======================================================

*** 6-month ahead forecast
ivreghdfe it6_all Treat [aw=peso], ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelA.dta", replace dec(3) dta 

tab time if e(sample)

*** 12-month ahead forecast
ivreghdfe it12_all Treat [aw=peso], ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelA.dta", append  dec(3) dta 
tab time if e(sample)


*** 24-month ahead forecast
ivreghdfe it24_all Treat [aw=peso], ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelA.dta", append  dec(3) dta 
tab time if e(sample)


*** 48-month ahead forecast
ivreghdfe it48_all Treat [aw=peso], ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelA.dta", append  dec(3) dta 
tab time if e(sample)

***======================================================
*** 			responses by horizon
***				consistent sample
***				Panel B
***======================================================
egen flag0=rownonmiss(it6_all it12_all  it24_all it48_all)

tab time if flag0==4
*** 6-month ahead forecast
ivreghdfe it6_all Treat [aw=peso] if flag0==4, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelB.dta", replace dec(3) dta 

*** 12-month ahead forecast
ivreghdfe it12_all Treat [aw=peso] if flag0==4, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelB.dta", append  dec(3) dta 


*** 24-month ahead forecast
ivreghdfe it24_all Treat [aw=peso] if flag0==4, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelB.dta", append  dec(3) dta 


*** 48-month ahead forecast
ivreghdfe it48_all Treat [aw=peso] if flag0==4, ///
	dkraay(2) absorb(i.setton5#i.trimestre)
outreg2 using "`out2'Table01_panelB.dta", append  dec(3) dta 

